package com.jymj.service.impl;

import com.jymj.dao.PjProjDao;
import com.jymj.entity.PjProjEntity;
import com.jymj.service.PjProjService;
import com.jymj.service.SysProjXzqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by dl on 2017/7/21.
 */
@Service("pjProjService")
public class PjProjServiceImpl implements PjProjService {

    @Autowired
    private PjProjDao pjProjDao;
    @Autowired
    private SysProjXzqService sysProjXzqService;

    @Override
    public PjProjEntity queryObject(Integer projId) {
        return pjProjDao.queryObject(projId);
    }

    @Override
    public List<PjProjEntity> queryList(Map<String, Object> map) {
        return pjProjDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return pjProjDao.queryTotal();
    }

    @Override
    public void save(PjProjEntity proj) {
        if (proj == null) {
            return;
        }
        proj.setCreateDate(new Date());
        pjProjDao.save(proj);
        sysProjXzqService.save(proj.getId(), proj.getXzqIdList());
    }

    @Override
    public void update(PjProjEntity proj) {
        if (proj == null) {
            return;
        }
        //修改项目本身
        pjProjDao.update(proj);
        //修改项目和行政区关系
        sysProjXzqService.update(proj.getId(), proj.getXzqIdList());
    }

    @Override
    public void deleteBatch(Integer[] projIds) {
        pjProjDao.deleteBatch(projIds);
    }

    @Override
    public List<PjProjEntity> queryList(long userId) {
        return pjProjDao.queryListByUser(userId);
    }

    @Override
    public List<PjProjEntity> queryTotalPro() {
        return pjProjDao.queryTotalPro();
    }

    @Override
    public Map<String, Object> queryMapCenter(String xzqName) {
        return pjProjDao.queryMapCenter(xzqName);
    }

    @Override
    public List<PjProjEntity> projSummary(Long userId) {
        return pjProjDao.projSummary(userId);
    }

    @Override
    public void delete(Integer id) {
        pjProjDao.delete(id);
    }

}
